﻿<ResourceDictionary 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:sys="clr-namespace:System;assembly=mscorlib"
    xmlns:v="clr-namespace:ShredTheLog.Views;assembly=ShredTheLog.Views"
    xmlns:vm="clr-namespace:ShredTheLog.ViewModels;assembly=ShredTheLog.ViewModels"
    xmlns:cnv="clr-namespace:ShredTheLog.Converters;assembly=ShredTheLog.Converters"
    xmlns:api="clr-namespace:ShredTheLog.Api;assembly=ShredTheLog.Api"
    xmlns:c="clr-namespace:ShredTheLog.Controls;assembly=ShredTheLog.Controls"
    xmlns:tk="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit"
    >

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="FlashMisc2.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <DataTemplate DataType="{x:Type vm:TextChatViewModel}">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="2*"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="1*"/>
            </Grid.ColumnDefinitions>
            
            <DockPanel Grid.Column="0">
                <AccessText DockPanel.Dock="Top" HorizontalAlignment="Stretch" TextAlignment="Center" TextTrimming="CharacterEllipsis" Text="{Binding Path=Users.Count, StringFormat={c:LocalizedString s_ConnectedUsers}}" Style="{StaticResource AccessHeaderStyle}"/>
                <tk:DataGrid ItemsSource="{Binding Users}">
                    <ItemsControl.ItemContainerStyle>
                        <Style TargetType="{x:Type tk:DataGridRow}">
                            <Setter Property="ContextMenu">
                                <Setter.Value>
                                    <ContextMenu c:Extensions.Items="{Binding Converter={x:Static vm:UserMenuItemsConverter.Default}}" DataContext="{Binding RelativeSource={RelativeSource Mode=Self}, Path=PlacementTarget.DataContext}"/>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </ItemsControl.ItemContainerStyle>
                    <tk:DataGrid.Columns>
                        <tk:DataGridTemplateColumn Header="{x:Null}" CanUserResize="False" SortMemberPath="Gender">
                            <tk:DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <ContentPresenter Content="{Binding Gender}" HorizontalAlignment="Center"/>
                                </DataTemplate>
                            </tk:DataGridTemplateColumn.CellTemplate>
                        </tk:DataGridTemplateColumn>
                        <tk:DataGridTextColumn Header="{c:LocalizedString s_Name}" Binding="{Binding Name}" Width="*"/>
                        <tk:DataGridTextColumn Header="{c:LocalizedString s_NativeLanguages}" Binding="{Binding Path=KnownLanguages, Converter={x:Static cnv:LanguagesConverter.Default}}" c:Extensions.Comparer="{x:Static cnv:ShortUserInfoByKnownLanguagesComparer.Default}" Width="2*"/>
                        <tk:DataGridTextColumn Header="{c:LocalizedString s_PracticingLanguages}" Binding="{Binding Path=PracticingLanguages, Converter={x:Static cnv:LanguagesConverter.Default}}" c:Extensions.Comparer="{x:Static cnv:ShortUserInfoByPracticingLanguagesComparer.Default}" Width="2*"/>
                        <tk:DataGridTextColumn Header="{c:LocalizedString s_Country}" Binding="{Binding Path=Country, Converter={x:Static cnv:CountryConverter.Default}}" c:Extensions.Comparer="{x:Static cnv:ShortUserInfoByCountryComparer.Default}" Width="*"/>
                        <tk:DataGridTextColumn Header="{c:LocalizedString s_Age}" Binding="{Binding Age}">
                            <tk:DataGridTextColumn.ElementStyle>
                                <Style TargetType="{x:Type TextBlock}">
                                    <Setter Property="TextAlignment" Value="Right"/>
                                </Style>
                            </tk:DataGridTextColumn.ElementStyle>
                        </tk:DataGridTextColumn>
                    </tk:DataGrid.Columns>
                </tk:DataGrid>
            </DockPanel>

            <GridSplitter Grid.Column="1" VerticalAlignment="Stretch" HorizontalAlignment="Center" Focusable="False" Width="3"/>

            <DockPanel Grid.Column="2">
                <AccessText DockPanel.Dock="Top" Text="{c:LocalizedString s_PublicChatRooms}" HorizontalAlignment="Stretch" TextAlignment="Center" TextTrimming="CharacterEllipsis" Style="{StaticResource AccessHeaderStyle}"/>
                <ItemsControl ItemsSource="{Binding JoinPublicChatRoomCommands}" Width="Auto" Focusable="False">
                    <ItemsControl.Template>
                        <ControlTemplate TargetType="{x:Type ItemsControl}">
                            <ScrollViewer ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.HorizontalScrollBarVisibility="Disabled" Focusable="False">
                                <ItemsPresenter/>
                            </ScrollViewer>
                        </ControlTemplate>
                    </ItemsControl.Template>
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <BulletDecorator Margin="0,2,0,0">
                                <BulletDecorator.Bullet>
                                    <Border CornerRadius="3" Background="LightGray">
                                        <Image Grid.Column="0" Source="{Binding Value.Image}" Width="30" Height="20" Stretch="Uniform" Margin="3"/>
                                    </Border>
                                </BulletDecorator.Bullet>

                                <TextBlock Grid.Column="1" Margin="3,0,0,0" VerticalAlignment="Center">
                                    <Hyperlink Command="{Binding Value}">
                                        <TextBlock Text="{Binding Path=Value.Name}"/>
                                    </Hyperlink>
                                </TextBlock>
                            </BulletDecorator>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>
            </DockPanel>

            <ProgressBar Grid.Column="0" Grid.ColumnSpan="3" Width="32" Height="32" HorizontalAlignment="Center" VerticalAlignment="Center" IsIndeterminate="True" Visibility="{Binding Path=IsLoading, Converter={StaticResource BoolToVisibilityConverter}}"/>
        </Grid>
    </DataTemplate>
</ResourceDictionary>